import dayjs from 'dayjs';
import { ComponentWithComputed } from 'miniprogram-computed';

ComponentWithComputed({
  properties: {
    value: {
      type: Object,
      value: {
        scenario_text: '',
        theme: '',
        using_date: dayjs().format('YYYY-MM-DD'),
        customer_name: '',
        customer_phone: '',
        date: dayjs().format('YYYY-MM-DD'),
        time_interval_text: '晚宴',
        remark: '',
      },
    },
  },
  computed: {
    showActivityDate(data) {
      return dayjs(data.value?.using_date).format('YYYY.MM.DD');
    },
    showReserveDate(data) {
      return dayjs(data.value?.date).format('YYYY.MM.DD');
    },
    activityTypeClass(data) {
      const classMap = {
        婚礼版: 'activity-type--wedding',
        企业版: 'activity-type--enterprise',
        生日版: 'activity-type--birthday',
        校园版: 'activity-type--campus',
      };
      const activityType = data.value.scenario_text as keyof typeof classMap;
      return classMap?.[activityType] || '';
    },
  },
  methods: {
    async onClickWechat() {
      const res = await wx.setClipboardData({
        data: this.data.value.customer_phone,
      });
      if (res) {
        wx.showToast({
          title: '已复制手机号，请去添加好友吧',
          icon: 'none',
        });
      }
    },
    onClickPhone() {
      wx.makePhoneCall({
        phoneNumber: this.data.value.customer_phone,
      });
    },
  },
});
